package com.ywf.corebase.common.exception;


import com.ywf.corebase.framework.enums.ResultCodeEnum;

/**
 * ClassName:BusinessException
 * Package:com.ywf.myproject.common.exception
 * Description:
 *
 * @Date:2021/2/28 17:55
 * @Author:YWF
 */
public class BusinessException extends RuntimeException{

    public static final long serialVersionUID = 4608624215695127158L;

    private Integer code;

    /**
     * 构造方法，基础异常处理类
     * @param code
     * @param message
     */
    public BusinessException(Integer code, String message){
        super(message);
        this.code = code;
    }

    /**
     * 构造方法，基础异常处理类
     * @param resultCodeEnum
     */
    public BusinessException(ResultCodeEnum resultCodeEnum){
        super(resultCodeEnum.getMsg());
        this.code = resultCodeEnum.getCode();
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String toString() {
        return "BusinessException{" +
                "code=" + code +
                '}';
    }
}
